<?php

namespace app\model;

use think\Model;

class SystemBusinessCommissionRatio extends Model
{
    /**
     * 业务提成比例库
     */

    protected $createTime='create_date';

    public function addDataModel($data)
    {
        return self::create($data);
    }

    /**
     * 获取业务ID对应的所有提成比例
     * @param $bid
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getBidDataModel($bid)
    {
        return $this->where (['business_id'=>$bid])->select ()->toArray ();
    }

    /**
     * 获取区间业务提成比例
     * @param $bid
     * @param $field
     * @param $field2
     * @return mixed
     */
    public function getBidBetweenValueModel($bid,$field,$field2)
    {
        return $this->where (['business_id'=>$bid])
            ->where('field','<',$field)
            ->where('field2','>=',$field2)
            ->value('value');
    }

    /**
     * 删除某个业务所有提成比例
     * @param $bid
     * @return bool
     */
    public function delBidModel($bid)
    {
        return $this->where (['business_id'=>$bid])->delete();
    }
}